#include "APopUpScreen.h"

using namespace SDL::UTILS;
using namespace SDL::ELEMENTS;

PopUpArgs::PopUpArgs(SDL_Surface* _screen, SDL_Event* _event) : MyScreenArgs(_screen, _event)
{
}

PopUpArgs::~PopUpArgs()
{
}

APopUpScreen::APopUpScreen() : IScreen(), m_background(NULL), m_pbOk(L"Ok")
{
	m_pbOk.SetPosition(Rect(500, 450));
}

APopUpScreen::~APopUpScreen()
{
	if (m_background != NULL)
		delete m_background;
}

void APopUpScreen::Draw(SDL::UTILS::IArgs* _args)
{
	PopUpArgs* pua = dynamic_cast<PopUpArgs*>(_args);

	if (m_background != NULL)
		m_background->Draw(pua->Screen);
	m_pbOk.Draw(pua->Screen);
}

void APopUpScreen::Exec(SDL::UTILS::IArgs* _args)
{
	PopUpArgs* pua = dynamic_cast<PopUpArgs*>(_args);
	
	m_pbOk.UpdateState();
	if (m_pbOk.GetState() == SDL::BUTTON::STATE::CLICKED)
		pua->Value = 1;
	if (pua->Event->type == SDL_KEYDOWN)
		if (pua->Event->key.keysym.sym)
			pua->Value = 1;
}
